package com.example.teamtribe.main.chat;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.example.teamtribe.main.chat.friends.FriendsFragment;
import com.example.teamtribe.main.chat.recent.RecentFragment;

public class ChatPagerAdapter extends FragmentPagerAdapter {

    private RecentFragment fragRecent;
    private FriendsFragment fragFriends;
    //private GroupFragment fragGroup;
    private String[] titles = new String[] {"最新", "好友"};

    public ChatPagerAdapter(FragmentManager fm) {
        super(fm);
        fragRecent = new RecentFragment();
        fragFriends = new FriendsFragment();
        //fragGroup = new GroupFragment();
    }

    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                return fragRecent;
            case 1:
                return fragFriends;
            //case 2:
                //return fragGroup;
            default:
                return fragRecent;
        }
    }

    @Override
    public int getItemPosition(Object object) {
        if (object instanceof RecentFragment) {
            return 0;
        } else if (object instanceof FriendsFragment) {
            return 1;
        } //else {
            //return 2;
        //}
        return 0;
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
